package com.edu.whty.common.tools;

import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * 教材资源--分表工具类
 */
public class FenbiaoUtil {
	
	public static final List<String> TB_COURSE_USER_SUFFIXS = 
			new ArrayList<String>(Arrays.asList("0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","n","s"));
	
	public static final List<String> TB_COURSE_RES_SUFFIXS = 
			new ArrayList<String>(Arrays.asList("0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"));
	
	/**
	 * 获取TB_COURSE_USER分表后缀
	 * @param userId
	 * @return
	 */
	public static String getTbCourseUserSuffix(String userId){
		if(StringUtils.isEmpty(userId) || !TB_COURSE_USER_SUFFIXS.contains((userId.charAt(0)+"").toLowerCase())){
			return "_default";
		}else{
			return "_" + (userId.charAt(0)+"").toLowerCase();
		}
	}
	
	/**
	 * 获取TB_COURSE_RES分表后缀
	 * @param resId
	 * @return
	 */
	public static String getTbCourseResSuffix(String resId){
		if(StringUtils.isEmpty(resId) || !TB_COURSE_RES_SUFFIXS.contains((resId.charAt(0)+"").toLowerCase())){
			return "_default";
		}else{
			return "_" + (resId.charAt(0)+"").toLowerCase();
		}
	}
}
